package br.com.passoumfmda.view;
import java.awt.event.ActionEvent;
import java.io.File;

import javax.swing.AbstractAction;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

import org.jdesktop.application.Action;
import org.jdesktop.application.Application;
import org.jdesktop.application.ApplicationActionMap;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class GUI extends javax.swing.JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JLabel jLabel2;
	private JLabel jLabel3;
	private JLabel jLabel4;
	private JTextField txtUsuario;
	private JLabel jLabel5;
	private JMenuItem jMenuItem1;
	private JMenu menuMeAjude;
	private JMenu menuAjuda;
	private JButton btnSair;
	private JButton btnLimpar;
	private JButton btnOk;
	private ButtonGroup buttonGroup1;
	private JMenu jMenu1;
	private JButton btnPesquisar;
	private JTextField txtPasta;
	private JLabel jLabel6;
	private JRadioButton radioOracle;
	private JRadioButton radioDb2;
	private JRadioButton radioSql;
	private JMenuItem jMenuItem5;
	private JSeparator jSeparator1;
	private JMenuItem jMenuItem4;
	private JMenuItem jMenuItem3;
	private JMenuItem jMenuItem2;
	private JTextField txtBaseName;
	private JPasswordField txtSenha;
	private JTextField txtPorta;
	private JTextField txtServidor;
	private JLabel jLabel1;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				GUI inst = new GUI();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public GUI() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				final JMenuBar jMenuBar1 = new JMenuBar();
				setJMenuBar(jMenuBar1);
				jMenuBar1.add(getJMenu1());
				jMenuBar1.add(getMenuAjuda());
				jMenuBar1.add(getMenuMeAjude());
				jMenuBar1.setVisible(true);
			}
			{
				jLabel1 = new JLabel();
				getContentPane().add(getJLabel6());
				getContentPane().add(getTxtPasta());
				getContentPane().add(getBtnSair());
				getContentPane().add(getBtnPesquisar());
				getContentPane().add(getBtnOk());
				getContentPane().add(getBtnLimpar());
				getContentPane().add(jLabel1);
				getButtonGroup1().add(getRadioDb2());
				getButtonGroup1().add(getRadioOracle());
				getButtonGroup1().add(getRadioSql());
				jLabel1.setBounds(12, 12, 197, 15);
				jLabel1.setName("jLabel1");
			}
			{
				txtServidor = new JTextField();
				getContentPane().add(txtServidor);
				getContentPane().add(getRadioSql());
				getContentPane().add(getRadioDb2());
				getContentPane().add(getRadioOracle());
				txtServidor.setBounds(12, 33, 197, 22);
			}
			{
				jLabel2 = new JLabel();
				getContentPane().add(jLabel2);
				jLabel2.setBounds(233, 12, 69, 15);
				jLabel2.setName("jLabel2");
			}
			{
				txtPorta = new JTextField();
				getContentPane().add(txtPorta);
				txtPorta.setBounds(233, 33, 69, 22);
				txtPorta.setName("txtPorta");
			}
			{
				jLabel3 = new JLabel();
				getContentPane().add(jLabel3);
				jLabel3.setBounds(329, 12, 189, 15);
				jLabel3.setName("jLabel3");
			}
			{
				txtBaseName = new JTextField();
				getContentPane().add(txtBaseName);
				txtBaseName.setBounds(329, 33, 189, 22);
			}
			{
				jLabel4 = new JLabel();
				getContentPane().add(jLabel4);
				jLabel4.setBounds(12, 67, 148, 15);
				jLabel4.setName("jLabel4");
			}
			{
				txtUsuario = new JTextField();
				getContentPane().add(txtUsuario);
				txtUsuario.setBounds(12, 88, 239, 22);
				txtUsuario.setName("txtUsuario");
			}
			{
				jLabel5 = new JLabel();
				getContentPane().add(jLabel5);
				getContentPane().add(getTxtSenha());
				jLabel5.setBounds(280, 67, 140, 15);
				jLabel5.setName("jLabel5");
			}
			pack();
			this.setSize(540, 330);
			Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(getContentPane());
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	private ButtonGroup getButtonGroup1() {
		if(buttonGroup1 == null) {
			buttonGroup1 = new ButtonGroup();
		}
		return buttonGroup1;
	}
	
	private JRadioButton getRadioSql() {
		if(radioSql == null) {
			radioSql = new JRadioButton();
			radioSql.setBounds(12, 129, 127, 19);
			radioSql.setName("radioSql");
		}
		return radioSql;
	}
	
	private JRadioButton getRadioDb2() {
		if(radioDb2 == null) {
			radioDb2 = new JRadioButton();
			radioDb2.setBounds(147, 129, 133, 19);
			radioDb2.setName("radioDb2");
		}
		return radioDb2;
	}
	
	private JRadioButton getRadioOracle() {
		if(radioOracle == null) {
			radioOracle = new JRadioButton();
			radioOracle.setBounds(291, 129, 136, 19);
			radioOracle.setName("radioOracle");
		}
		return radioOracle;
	}
	
	private JLabel getJLabel6() {
		if(jLabel6 == null) {
			jLabel6 = new JLabel();
			jLabel6.setBounds(12, 156, 424, 15);
			jLabel6.setName("jLabel6");
		}
		return jLabel6;
	}
	
	private JTextField getTxtPasta() {
		if(txtPasta == null) {
			txtPasta = new JTextField();
			txtPasta.setBounds(12, 178, 424, 22);
		}
		return txtPasta;
	}
	
	private JButton getBtnPesquisar() {
		if(btnPesquisar == null) {
			btnPesquisar = new JButton();
			btnPesquisar.setBounds(464, 178, 54, 21);
			btnPesquisar.setName("btnPesquisar");
			btnPesquisar.setMargin(new java.awt.Insets(0, 0, 0, 0));
			btnPesquisar.setAction(acaoPesquisarPasta());
		}
		return btnPesquisar;
	}
	
	private JMenu getJMenu1() {
		if(jMenu1 == null) {
			jMenu1 = new JMenu();
			jMenu1.setName("jMenu1");
			jMenu1.add(getJMenuItem3());
			jMenu1.add(getJMenuItem4());
			jMenu1.add(getJSeparator1());
			jMenu1.add(getJMenuItem5());
		}
		return jMenu1;
	}
	
	private JButton getBtnOk() {
		if(btnOk == null) {
			btnOk = new JButton();
			btnOk.setBounds(434, 239, 84, 21);
			btnOk.setName("btnOk");
			btnOk.setMargin(new java.awt.Insets(0, 0, 0, 0));
		}
		return btnOk;
	}
	
	private JButton getBtnLimpar() {
		if(btnLimpar == null) {
			btnLimpar = new JButton();
			btnLimpar.setBounds(339, 239, 84, 21);
			btnLimpar.setName("btnLimpar");
			btnLimpar.setMargin(new java.awt.Insets(0, 0, 0, 0));
		}
		return btnLimpar;
	}
	
	private JButton getBtnSair() {
		if(btnSair == null) {
			btnSair = new JButton();
			btnSair.setBounds(249, 239, 79, 21);
			btnSair.setName("btnSair");
			btnSair.setMargin(new java.awt.Insets(0, 0, 0, 0));
		}
		return btnSair;
	}
	
	private JMenu getMenuAjuda() {
		if(menuAjuda == null) {
			menuAjuda = new JMenu();
			menuAjuda.setName("menuAjuda");
			menuAjuda.add(getJMenuItem1());
			menuAjuda.add(getJMenuItem2());
		}
		return menuAjuda;
	}
	
	private JMenu getMenuMeAjude() {
		if(menuMeAjude == null) {
			menuMeAjude = new JMenu();
			menuMeAjude.setName("menuMeAjude");
		}
		return menuMeAjude;
	}
	
	private JMenuItem getJMenuItem1() {
		if(jMenuItem1 == null) {
			jMenuItem1 = new JMenuItem();
			jMenuItem1.setName("jMenuItem1");
		}
		return jMenuItem1;
	}
	
	private JMenuItem getJMenuItem2() {
		if(jMenuItem2 == null) {
			jMenuItem2 = new JMenuItem();
			jMenuItem2.setName("jMenuItem2");
		}
		return jMenuItem2;
	}
	
	private JMenuItem getJMenuItem3() {
		if(jMenuItem3 == null) {
			jMenuItem3 = new JMenuItem();
			jMenuItem3.setName("jMenuItem3");
		}
		return jMenuItem3;
	}
	
	private JMenuItem getJMenuItem4() {
		if(jMenuItem4 == null) {
			jMenuItem4 = new JMenuItem();
			jMenuItem4.setName("jMenuItem4");
		}
		return jMenuItem4;
	}
	
	private JSeparator getJSeparator1() {
		if(jSeparator1 == null) {
			jSeparator1 = new JSeparator();
		}
		return jSeparator1;
	}
	
	private JMenuItem getJMenuItem5() {
		if(jMenuItem5 == null) {
			jMenuItem5 = new JMenuItem();
			jMenuItem5.setName("jMenuItem5");
		}
		return jMenuItem5;
	}
	
	@Action
	public AbstractAction acaoPesquisarPasta() {
		return new AbstractAction() {
			private static final long serialVersionUID = 1L;
			public void actionPerformed(ActionEvent evento) {
				String pasta = "";
				if (txtPasta.getText() != null && !txtPasta.getText().equals("")) {
					pasta = txtPasta.getText();
				}
				JFileChooser fc = new JFileChooser();
				fc.setCurrentDirectory(new File(pasta));
				fc.setDialogTitle("Selecione uma pasta para gravação das procedures");
				fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
				fc.setNextFocusableComponent(null);
				int opcao = fc.showOpenDialog(getContentPane());
				if (opcao == JFileChooser.APPROVE_OPTION) {
					txtPasta.setText(fc.getSelectedFile().getAbsolutePath());
				}
			}
		};
	}
	
    
    
    private JPasswordField getTxtSenha() {
    	if(txtSenha == null) {
    		txtSenha = new JPasswordField();
    		txtSenha.setBounds(280, 88, 238, 22);
    	}
    	return txtSenha;
    }

}
